package sctu.edu.java.year2016.team01.xuhanmei.day20160521.chapter5_2;

/**
 * Created by Administrator on 2016/5/21.
 * 写一个一维数组，求其最大者
 */
public class traversearray2 {

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
        System.out.println("一维数组里的数有：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }


        System.out.println("\n");


        int max = arr[0];
        for (int j = 0; j < arr.length - 1; j++) {
            if (max < arr[j + 1]) {
                max = arr[j + 1];
            }
        }
        System.out.println("一维数组中的最大数是：" + max);
    }
}
